<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('异常工时列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>姓名：</label>
                                <input type="text" name="params[userName]"/>
                            </li>
                            <li class="select-time">
                                <label>异常日期：</label>
                                <input type="text" class="time-input"  id="beginTime" placeholder="请选择工时日期" name="params[beginTime]" th:value="${beginTime}"/>
                                <span>-</span>
                                <input type="text" class="time-input"  id="endTime" placeholder="请选择工时日期" name="params[endTime]" th:value="${endTime}"/>
                                <span><a  onclick="prevWeek()">上周</a> <a  onclick="nextWeek()">下周</a></span>

                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-info" onclick="$.operate.add()" shiro:hasPermission="erp:projectHourAbnormal:add">
                    <i class="fa fa-calculator"></i> 更新
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="erp:projectHourAbnormal:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="erp:projectHourAbnormal:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('erp:projectHourAbnormal:edit')}]];
        var removeFlag = [[${@permission.hasPermi('erp:projectHourAbnormal:remove')}]];
        var prefix = ctx + "erp/projectHourAbnormal";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                sortName: 'abnormal_date',
                sortOrder: 'DESC',
                modalName: "异常工时",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '',
                    visible: false
                },
                {
                    field: 'userName',
                    title: '姓名'
                },
                {
                    field: 'abnormalDate',
                    title: '异常日期'
                },
                {
                    field: 'lessHour',
                    title: '缺少工时'
                },
                {
                    field: 'description',
                    title: '异常描述'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        function prevWeek()
        {
            var date = new Date($('#beginTime').val());
            $('#endTime').val($('#beginTime').val());
            date.setDate(date.getDate() - 7);
            $('#beginTime').val(date.getFullYear() + '-' + (date.getMonth()+1) + '-' + date.getDate());
        }
        function nextWeek()
        {
            var date = new Date($('#beginTime').val());
            date.setDate(date.getDate() + 7);
            $('#beginTime').val(date.getFullYear() + '-' + (date.getMonth()+1) + '-' + date.getDate());
            date.setDate(date.getDate() + 7);
            $('#endTime').val(date.getFullYear() + '-' + (date.getMonth()+1) + '-' + date.getDate());
        }
    </script>
</body>
</html>